package com.qf.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.qf.entity.Order;
import com.qf.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderServiceImpl {

    @Autowired
    private OrderMapper orderMapper;

    public void addOrder(Order order) {


        DynamicDataSourceContextHolder.push("order-2");

        // 插入订单的表
        orderMapper.insert(order);
        System.out.println("===========================");
        order.setUid(10);
//        int i  = 10/0;

        // 插入订单详情
        order.setId(System.currentTimeMillis()+"3");
        orderMapper.insert(order);

    }
}
